/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2017-2019. All rights reserved.
 * Description: Parse dts information from aac's head
 * Author: HiMobileCam middleware develop team
 * Create: 2017-12-22
 */

#ifndef AACPARSER_H
#define AACPARSER_H

#include "hi_mw_type.h"

typedef struct {
    /* fixed */
    HI_U32 sync;        /* syncword */
    HI_U8 id;            /* MPEG bit - should be 1 */
    HI_U8 layer;         /* MPEG layer - should be 0 */
    HI_U8 protectBit;    /* 0 : CRC word follows, 1 : no CRC word */
    HI_U8 pofile;       /* 0 : main, 1 : LC, 2 : SSR, 3 : reserved */
    HI_U8 sampRateIdx;   /* sample rate index range : [0, 11] */
    HI_U8 privateBit;    /* ignore */
    HI_U8 channelConfig; /* 0 : implicit, >0 : use default table */
    HI_U8 origCopy;      /* 0 : copy, 1 : original */
    HI_U8 home;          /* ignore */

    /* variable */
    HI_U8 copyBit;          /* 1 bit of the 72-bit copyright ID (transmitted as 1 bit per frame) */
    HI_U8 copyStart;        /* 1 : this bit starts the 72-bit ID, 0 : it does not */
    HI_U32 frameLength;    /* length of frame */
    HI_U32 bufferFull;     /* number of 32-bit words left in enc buffer,0x7FF : VBR */
    HI_U8 numRawDataBlocks; /* number of raw data blocks in frame */

    /* CRC */
    HI_S32 crcCheckWord; /* 16-bit CRC check word (present if protectBit : 0) */
} AacAdtsHeader;

HI_S32 FFAACParserParseAdtsHeader(const HI_U8 *data, HI_U32 dataLen,
    AacAdtsHeader *outHeader, HI_U32 *outHeaderLen);

#endif
